package com.cjm.one.webmanager.service.goods.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjm.one.goods.client.GoodsCategoryClient;
import com.cjm.one.model.goods.entity.GoodsCategory;
import com.cjm.one.model.goods.vo.GoodsCategoryVo;
import com.cjm.one.webmanager.service.goods.GoodsCategoryService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsCategoryServiceImpl implements GoodsCategoryService {
    @Resource
    private GoodsCategoryClient goodsCategoryClient;
    @Override
    public List<GoodsCategoryVo> list(String searchKey) {
        return goodsCategoryClient.getPage(searchKey).getData();
    }

    @Override
    public GoodsCategoryVo getByIdVo(Long id) {
        return goodsCategoryClient.getById(id).getData();
    }

    @Override
    public Boolean updateById(GoodsCategory goodsCategory) {
        return goodsCategoryClient.update(goodsCategory).getData();
    }

    @Override
    public Boolean save(GoodsCategory goodsCategory) {
        return goodsCategoryClient.save(goodsCategory).getData();
    }

    @Override
    public Boolean removeById(Long id) {
        return goodsCategoryClient.delete(id).getData();
    }

    @Override
    public List<GoodsCategory> listByParentId(Long parentId) {
        return  goodsCategoryClient.getToParentId(parentId).getData();
    }
}
